<?php
//----------------------------------------------------------------------------//
// File               : 										  //
// Modification       :														  //
//----------------------------------------------------------------------------//
// Date(yyyy.mm.dd)   Developer                       Action				  //
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// 2007.07.11         Dang Thanh                      Update				  //
//----------------------------------------------------------------------------//
?>
<?php
function V_HangsxAdd(&$arrayData,$mode)
{
	$mode=CM_getParameter("action");
	global $arrayError;
	
	$ulr = "?".MODUL."=hangsx&".ACTION."=".$mode;//htmlspecialchars($_SERVER['QUERY_STRING']);
	$strButtonLabel =" Ghi lại ";
	$strLabel ="Sửa lại thông tin hãng sản xuất";
	if ($mode == "Add"){
		$strButtonLabel ="Thêm mới";	
		$strLabel ="Thêm mới thông tin hãng sản xuất";
	}	
	$strHienThi1 = 'checked="checked"';
	$strHienThi0 = '';
	if($arrayData["hien_thi"]==0 && $mode!="Add"){
		$strHienThi1 = '';
		$strHienThi0 = 'checked="checked"';
	}
	//	htmlentities(
	?>
	<script language=javascript>
	function doUpload() {
		if (document.f.ten_hang.value=="") {
			alert("Tên hãng sản xuất không được rỗng");
			document.f.ten_hang.focus();
			return false;
		}
		if (document.f.thu_tu.value=="") {
			alert("thứ tự hiển thị không được rỗng");
			document.f.thu_tu.focus();
			return false;
		}		
		if (isNaN(document.f.thu_tu.value)) {
			alert("Thứ tự sắp xếp phải là kiểu số");
			document.f.thu_tu.value="";
			document.f.thu_tu.focus();
			return false;
		}	
		
		var filename = document.f.userfile.value;
		var dotpos;
		filename = filename.substring(filename.lastIndexOf("\\")+1,filename.length);
		dotpos=filename.lastIndexOf('.');
		ext=filename.substr(dotpos+1,3);
		ext=ext.toLowerCase();
		fname=filename.substr(0,dotpos);
		if (document.f.userfile.value!="") {
			if(dotpos==-1||dotpos==0){
				alert("Xin lỗi bạn click vào browser để chọn đúng đường dẫn.");
				return false;
			}
		}
	
		if (ext!="")
			if ((ext!="gif") && (ext!="jpg") && (ext!="png")  && (ext!="bmp")){
				alert("We only accept file format of GIF, JPG, PNG. Please try again.");
				return false;
			}


		return true;
	}
	

function showImage(urlimage)
{
	
	if(document.f.userfile.value!=""){
		choseImage(document.f.userfile.value);
		
	}else{
		choseImage(urlimage);
	}
}


function btnClearImgOnclick(){
	if (document.f.userfile.value != ""){
		if (confirm("Bạn có muốn xóa ảnh không?")){
			document.f.previewField.src = "";
			//document.f.chu_thich_anh.value = "";
			document.getElementById("fn").value='';
			document.getElementById("fileIDSpan").innerHTML=
					"<input name=\"userfile\" type=\"file\" id=\"fn\"  size=\"100\" value=\"\" onChange=\" showImage();\"/>";
		}
	}
}
function Focus(){
document.f.ten_hang.focus();
}
</script>
<?= CM_showError() ?>
<style type="text/css">
<!--
.style2 {color: #000066}
-->
</style>
<body onLoad="Focus();">
<table width="100%">
  <tr><td>
 <form enctype="multipart/form-data" action="<?=$ulr;?>" method="post" name="f" id="f" onSubmit="return doUpload();">
	<input type="hidden" name="id" value="<?=htmlspecialchars($arrayData["id"])?>" />
	<input type="hidden" name="curPg" value="<?=CM_getParameter("curPg");?>" /> 
<TABLE width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white">
    <TBODY>
      <TR align="center" bgcolor="#FFE59F">
        <TD width="100%" height="17" align="center" valign="middle" id=th1><strong><?=$strLabel?></strong></TD>
      </TR>
    </TBODY>
  </table>
  <TABLE width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white">
     <TBODY>
      <TR>
        <TD width="20%" height="22" bgcolor="#FFE59F"  class=bk12-140>
		<span  style="font-family:Arial; font-size:14px; color:#000066; ">Tên hãng sản xuất:<span style="color:#FF0000;">*</span></span></TD>
        <TD width="80%" align="left"  class=bk12-140>
          <input name="ten_hang" type="text" id="ten_hang" value="<?=htmlspecialchars($arrayData["ten_hang"])?>" style="width:400px; " maxlength="30" />
        </TD>
      </TR>
      <tr>
      	<TD width="20%" height="22" bgcolor="#FFE59F"  class=bk12-140>
		<span  style="font-family:Arial; font-size:14px; color:#000066; ">Icon hãng sản xuất:<span style="color:#FF0000;">*</span></span></TD>
        <TD width="80%" align="left"  class=bk12-140>
           
        	<?
		  	if($mode=="Edit" && $arrayData["ten_anh"] != ''){
			  ?>
			 <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <?=htmlspecialchars($arrayData["ten_anh"])?>
			 </font><br>
			 <?
				}else{}
			 ?>
		 	 <span id="fileIDSpan">
            <input name="userfile" type="file" id="fn"  size="50" value="<?=htmlspecialchars($arrayData["ten_anh"])?>" onChange="showImage();"/>
           </span></font>	
		</TD>
      </tr>
	 
	  <TR>
        <TD height="22" bgcolor="#FFE59F" class=bk12-140><span class="style2">Thứ tự hiển thị:</span><span style="color:#FF0000;">*</span></TD>
        <TD  class=bk12-140>
          <input name="thu_tu" type="text" align="right" id="thu_tu" value="<?=htmlspecialchars($arrayData["thu_tu"])?>" size="4" maxlength="4" />
        </TD>
      </TR>
      <TR>
        <TD height="22" bgcolor="#FFE59F"  class=bk12-140><span style="font-family:Arial; font-size:14px; color:#000066;">Hiển th&#7883;:</span></TD>
        <TD align="left"  class=bk12-140>
          <input name="hien_thi" type="radio" value="1" <?=$strHienThi1?> / checked="checked">
		  <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			C&oacute;</label>
          <input name="hien_thi" type="radio" value="0" <?=$strHienThi0 ?> />
          <label> Kh&ocirc;ng</label>
        </TD>
      </TR>
     
    </TBODY>
	
  </TABLE>
  <TABLE width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white">
    <TBODY>
      <TR align="center" >
        <TD width="100%" height="17" align="center" valign="middle" id=th1><strong><span class="bk12-140"><strong>
          <input name="Reset" type="reset" value="Nhập lại" />
        </strong></span><span class="bk12-140"><strong>
        <input name="Submit" type="submit" value="<?=$strButtonLabel?>" />
        <strong>
		<script language = 'JavaScript' >
		function backToList(){
			location = '<?="?".MODUL."=hangsx&".ACTION."="."List"?>';
			return;
		}
		</script>
        <input type="button" name="back" value="Tr&#7903; l&#7841;i" onClick="javascript: return backToList();">
        </strong> </strong></span></strong></TD>
      </TR>
</TBODY>
</table>
</form>
</td></tr></table>
</body>
	  <?php
	}
?>

